package logic

import (
	"context"
	"goods_srv/goods"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type DelHouseLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDelHouseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DelHouseLogic {
	return &DelHouseLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DelHouseLogic) DelHouse(req *types.DelHouseRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	house, err := l.svcCtx.Goods.DelHouse(l.ctx, &goods.DelHouseRequest{
		UserId: req.UserId,
		Id:     req.Id,
	})
	if err != nil {
		return &types.Response{
			Code: 500,
			Msg:  err.Error(),
			Data: nil,
		}, nil
	}
	return &types.Response{
		Code: 200,
		Msg:  "房源删除成功",
		Data: house,
	}, nil
}
